package com.wpzf.ndhc.controller;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wpzf.common.core.utils.ServletUtils;
import com.wpzf.common.core.web.domain.AjaxResult;
import com.wpzf.common.security.service.TokenService;
import com.wpzf.ndhc.domain.*;
import com.wpzf.ndhc.service.*;
import com.wpzf.ndhc.utils.GTYUtil;
import com.wpzf.ndhc.utils.WpzfNdhcExcelUtils;
import com.wpzf.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.*;

@RestController
@RequestMapping("/wpzfndhc/common")
public class WpzfNdhcCommonController {

    @Autowired
    private WpzfNdhcCommonService wpzfNdhcCommonServiceImpl;

    @Autowired
    private WpzfNdhcTbhcjgService wpzfNdhcTbhcjgService;

    @Autowired
    private WpzfNdhcHcdwService wpzfNdhcHcdwService;

    @Autowired
    private WpzfNdhcJlHcTaskService wpzfNdhcJlHcTaskService;

    @Autowired
    private WpzfNdhcShTbService wpzfNdhcShTbService;

    @Autowired
    private WpzfNdhcZgTbTaskService wpzfNdhcZgTbTaskService;

    @Autowired
    private WpzfNdhcXjtbTbBaseService wpzfNdhcXjtbTbBaseService;

    @Autowired
    private WpzfNdhcTjInfoService wpzfNdhcTjInfoServiceImpl;

    @Autowired
    private TokenService tokenService;

    /*保存核查结果*/
    @Transactional
    @RequestMapping(value = "/addHcjg", method = RequestMethod.POST)
    public AjaxResult addHcjg(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            List<Map<String, Object>> list = new ArrayList<>();
            String selectList = param.get("listParams").toString();
            int rest = 0;
            String ywhj = param.get("ywhj") + "";
            if (!selectList.equals("") && !selectList.equals("null") && selectList != null) {
                JSONObject obj = JSON.parseObject(selectList);
                if (obj != null) {
                    param.put("user_name", loginUser.getUsername());
                    param.put("nick_name", loginUser.getSysUser().getNickName());
                    param.put("dwmc", loginUser.getSysUser().getDept().getDeptName());

                    param.put("sfhc", "是");
                    String strPdlx = param.get("pdlx") + "";

                    if (strPdlx.equals("已办理建设用地审批手续")) {
                        param.put("jl_jlpf", param.get("hf_jlJlpf"));
                    } else if (strPdlx.equals("应办理建设用地审批手续而未办理")) {
                        param.put("jl_jlpf", param.get("wf_jlJlpf"));
                    } else if (strPdlx.equals("其他")) {
                        param.put("jl_jlpf", param.get("qt_jlJlpf"));
                    }

                    String state = param.get("state") + "";
                    Map<String, Object> item = wpzfNdhcCommonServiceImpl.queryHcJgById(param);
                    if (item != null) {
                        wpzfNdhcCommonServiceImpl.deleteHcJg(param);
                        wpzfNdhcCommonServiceImpl.deleteHcjg_hf_dtPwwj(param);
                        wpzfNdhcCommonServiceImpl.deleteHcjg_wf_wfpzwh(param);
                        wpzfNdhcCommonServiceImpl.deleteHcjg_wf_wftgzmwj(param);
                        wpzfNdhcCommonServiceImpl.deleteHcjg_qt_qtpzwh(param);
                        wpzfNdhcCommonServiceImpl.deleteHcjg_qt_qtsftgxxydss(param);
                        wpzfNdhcCommonServiceImpl.deleteHcjg_qt_qtsfzygd(param);
                    }
                    rest = wpzfNdhcCommonServiceImpl.addHcjg(param);

                    String domains = param.get("domains") + "";
                    if (!domains.equals("[]") && !domains.equals("null") && domains != "null") {
                        JSONArray arraylist = JSONObject.parseArray(domains);

                        for (int i = 0; i < arraylist.size(); i++) { //遍历输出
                            JSONObject jsonObject = arraylist.getJSONObject(i);

                            if (strPdlx.equals("已办理建设用地审批手续")) {
                                Map<String, Object> map = new HashMap();
                                map.put("dkbsm", param.get("dkbsm"));
                                map.put("dkbh", param.get("dkbh"));
                                map.put("xzqdm", param.get("xzqdm"));
                                map.put("pch", param.get("pch"));
                                map.put("sort", jsonObject.getString("sort"));
                                map.put("hf_zlpwlx1", jsonObject.getString("hf_zlpwlx1"));
                                map.put("hf_pzwh", jsonObject.getString("hf_pzwh"));
                                map.put("hf_pzxmmc", jsonObject.getString("hf_pzxmmc"));
                                map.put("hf_pzzygdmj", jsonObject.getString("hf_pzzygdmj"));
                                map.put("hf_pzzygdmjdw", jsonObject.getString("hf_pzzygdmjdw"));
                                map.put("hf_pzsj", jsonObject.getString("hf_pzsj"));
                                map.put("hf_zlpwlx2", jsonObject.getString("hf_zlpwlx2"));
                                map.put("hf_zlpwclmc", jsonObject.getString("hf_zlpwclmc"));
                                map.put("ywhj", param.get("ywhj"));
                                wpzfNdhcCommonServiceImpl.addHcjg_hf_DtPwwj(map);
                            } else if (strPdlx.equals("应办理建设用地审批手续而未办理")) {
                                if (jsonObject.getString("wf_zlpwlx1") != null || jsonObject.getString("wf_zlpwlx2") != null) {
                                    Map<String, Object> map = new HashMap();
                                    map.put("dkbsm", param.get("dkbsm"));
                                    map.put("dkbh", param.get("dkbh"));
                                    map.put("xzqdm", param.get("xzqdm"));
                                    map.put("pch", param.get("pch"));
                                    map.put("sort", jsonObject.getString("sort"));
                                    map.put("wf_zlpwlx1", jsonObject.getString("wf_zlpwlx1"));
                                    map.put("wf_pzwh", jsonObject.getString("wf_pzwh"));
                                    map.put("wf_pzxmmc", jsonObject.getString("wf_pzxmmc"));
                                    map.put("wf_pzzygdmj", jsonObject.getString("wf_pzzygdmj"));
                                    map.put("wf_pzzygdmjdw", jsonObject.getString("wf_pzzygdmjdw"));
                                    map.put("wf_pzsj", jsonObject.getString("wf_pzsj"));

                                    map.put("wf_zlpwlx2", jsonObject.getString("wf_zlpwlx2"));
                                    map.put("wf_zlpwclmc", jsonObject.getString("wf_zlpwclmc"));
                                    map.put("ywhj", param.get("ywhj"));
                                    wpzfNdhcCommonServiceImpl.addHcjg_wf_wftgzmwj(map);
                                } else {
                                    Map<String, Object> map = new HashMap();
                                    map.put("dkbsm", param.get("dkbsm"));
                                    map.put("dkbh", param.get("dkbh"));
                                    map.put("xzqdm", param.get("xzqdm"));
                                    map.put("pch", param.get("pch"));
                                    map.put("sort", jsonObject.getString("sort"));
                                    map.put("wf_pzwh", jsonObject.getString("wf_pzwh"));
                                    map.put("wf_pzxmmc", jsonObject.getString("wf_pzxmmc"));
                                    map.put("wf_pzsj", jsonObject.getString("wf_pzsj"));
                                    map.put("ywhj", param.get("ywhj"));
                                    wpzfNdhcCommonServiceImpl.addHcjg_wf_wfpzwh(map);
                                }
                            } else if (strPdlx.equals("其他")) {
                                if (jsonObject.getString("qt_pzwh") != null) {
                                    Map<String, Object> qtpzwh_map = new HashMap();
                                    qtpzwh_map.put("dkbsm", param.get("dkbsm"));
                                    qtpzwh_map.put("dkbh", param.get("dkbh"));
                                    qtpzwh_map.put("xzqdm", param.get("xzqdm"));
                                    qtpzwh_map.put("pch", param.get("pch"));
                                    qtpzwh_map.put("sort", jsonObject.getString("sort"));
                                    qtpzwh_map.put("qt_pzwh", jsonObject.getString("qt_pzwh"));
                                    qtpzwh_map.put("qt_pzxmmc", jsonObject.getString("qt_pzxmmc"));
                                    qtpzwh_map.put("qt_pzsj", jsonObject.getString("qt_pzsj"));
                                    qtpzwh_map.put("ywhj", param.get("ywhj"));
                                    wpzfNdhcCommonServiceImpl.adddHcjg_qt_qtpzwh(qtpzwh_map);
                                } else if (jsonObject.getString("qt_tgbawjsj") != null) {
                                    Map<String, Object> qtsfzygd_map = new HashMap();
                                    qtsfzygd_map.put("dkbsm", param.get("dkbsm"));
                                    qtsfzygd_map.put("dkbh", param.get("dkbh"));
                                    qtsfzygd_map.put("xzqdm", param.get("xzqdm"));
                                    qtsfzygd_map.put("pch", param.get("pch"));
                                    qtsfzygd_map.put("sort", jsonObject.getString("sort"));
                                    qtsfzygd_map.put("qt_tgbawjsj", jsonObject.getString("qt_tgbawjsj"));
                                    qtsfzygd_map.put("qt_clmc", jsonObject.getString("qt_clmc"));
                                    qtsfzygd_map.put("ywhj", param.get("ywhj"));
                                    wpzfNdhcCommonServiceImpl.addHcjg_qt_qtsfzygd(qtsfzygd_map);
                                } else if (jsonObject.getString("qt_sftgxxydssclmc") != null) {
                                    Map<String, Object> qtsftgxxydss_map = new HashMap();
                                    qtsftgxxydss_map.put("dkbsm", param.get("dkbsm"));
                                    qtsftgxxydss_map.put("dkbh", param.get("dkbh"));
                                    qtsftgxxydss_map.put("xzqdm", param.get("xzqdm"));
                                    qtsftgxxydss_map.put("pch", param.get("pch"));
                                    qtsftgxxydss_map.put("sort", jsonObject.getString("sort"));

                                    qtsftgxxydss_map.put("qt_sftgxxydssclmc", jsonObject.getString("qt_sftgxxydssclmc"));
                                    qtsftgxxydss_map.put("qt_sftgxxydsspfsj", jsonObject.getString("qt_sftgxxydsspfsj"));
                                    qtsftgxxydss_map.put("ywhj", param.get("ywhj"));
                                    wpzfNdhcCommonServiceImpl.addHcjg_qt_qtsftgxxydss(qtsftgxxydss_map);
                                }
                            }
                        }
                    }

                    Map<String, Object> model = new HashMap<String, Object>();
                    model.put("user_name", loginUser.getUsername());
                    model.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
                    model.put("dkbsm", param.get("dkbsm"));
                    model.put("dkbh", param.get("dkbh"));
                    model.put("xzqdm", obj.getString("xzqdm"));
                    model.put("pch", obj.getString("pch"));
                    model.put("pdlx", obj.getString("pdlx"));
                    model.put("sfhc", obj.getString("sfhc"));
                    model.put("keyword", obj.getString("keyword"));
                    model.put("ids", param.get("ids"));

                    model.put("status", state);

                    if (ywhj.equals("0") && state.equals("未完成")) {
                        model.put("xzqdm", param.get("xzqdm"));
                        list = wpzfNdhcHcdwService.queryDkTaskByIndex(model);
                    } else if (ywhj.equals("1") && state.equals("未完成")) {
                        list = wpzfNdhcJlHcTaskService.queryDkTaskByIndex(model);
                    } else if (ywhj.equals("2") && state.equals("待确认")) {
                        model.put("sfqr", obj.getString("sfqr"));
                        list = wpzfNdhcHcdwService.queryQrDkTaskByIndex(model);
                    } else if (ywhj.equals("3") && state.equals("待整改")) {
                        Map<String, Object> map = new HashMap<>();
                        map.put("user_name", loginUser.getUsername());
                        map.put("nick_name", loginUser.getSysUser().getNickName());
                        map.put("dkbh", param.get("dkbh"));
                        map.put("xzqdm", param.get("xzqdm"));
                        map.put("pch", param.get("pch"));
                        map.put("zg_submitdate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((new Date()).getTime()));
                        wpzfNdhcZgTbTaskService.update_unit_zgtb(map);
                        model.put("module", param.get("module"));
                        list = wpzfNdhcZgTbTaskService.queryDkTaskByIndex(model);
                    }
                }
            }
            //按照业务环节值  获取核查结果说明
            Map<String, Object> tbhcjgsm = wpzfNdhcCommonServiceImpl.getHcjgsmByDkbh(param);
            if (tbhcjgsm != null) {
                tbhcjgsm.put("ywhj", param.get("ywhj") + "");
                wpzfNdhcCommonServiceImpl.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
            }
            return AjaxResult.success("保存核查结果", list, rest);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("保存失败", e.getMessage());
        }
    }

    @RequestMapping(value = "/getHcjgsmByDkbh", method = RequestMethod.POST)
    public AjaxResult getHcjgsmByDkbh(@RequestBody Map<String, Object> param) {
        Map<String, Object> tbhcjgsm = wpzfNdhcCommonServiceImpl.getHcjgsmByDkbh(param);
        return AjaxResult.success("保存核查结果", tbhcjgsm);
    }

    /*获取上一个图斑*/
    @RequestMapping(value = "/get_last_tbbh", method = RequestMethod.POST)
    public AjaxResult get_last_tbbh(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        String ywhj = param.get("ywhj") + "";
        String state = param.get("state") + "";
        List<Map<String, Object>> list = new ArrayList<>();
        String selectList = param.get("listParams").toString();
        if (!selectList.equals("") && !selectList.equals("null") && selectList != null) {
            Map<String, Object> model = new HashMap<>();
            JSONObject obj = JSON.parseObject(selectList);
            if (obj != null) {
                model.put("user_name", loginUser.getUsername());
                model.put("nick_name", loginUser.getSysUser().getNickName());
                model.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
                model.put("dkbsm", param.get("dkbsm"));
                model.put("dkbh", param.get("dkbh"));
                model.put("xzqh", obj.getString("xzqh"));
                model.put("xzqdm", obj.getString("xzqdm"));
                model.put("pch", obj.getString("pch"));
                model.put("pdlx", obj.getString("pdlx"));
                model.put("sfhc", obj.getString("sfhc"));
                model.put("keyword", obj.getString("keyword"));
                model.put("ids", param.get("ids"));

                model.put("status", state);

                if (ywhj.equals("0") && state.equals("未完成")) {
                    model.put("xzqdm", param.get("xzqdm"));
                    list = wpzfNdhcHcdwService.queryDkTaskByIndex(model);
                } else if (ywhj.equals("0") && state.equals("已完成")) {
                    model.put("xzqdm", param.get("xzqdm"));
                    list = wpzfNdhcHcdwService.queryDkTaskByIndex(model);
                } else if (state.equals("核查单位管理员图斑管理")) {
                    model.put("jlzt", obj.getString("jlzt"));
                    model.put("sfxyqr", obj.getString("sfxyqr"));
                    model.put("sfxyzg", obj.getString("sfxyzg"));
                    model.put("zgzt", obj.getString("zgzt"));
                    list = wpzfNdhcHcdwService.queryDkTaskListByIndex(model);
                } else if (state.equals("监理核查管理员图斑管理")) {
                    model.put("sftj", obj.getString("sftj"));
                    model.put("sfxyqr", obj.getString("sfxyqr"));
                    model.put("sfxyzg", obj.getString("sfxyzg"));
                    model.put("zgzt", obj.getString("zgzt"));
                    list = wpzfNdhcHcdwService.queryDkTaskListByIndex(model);
                } else if (ywhj.equals("1") && state.equals("未完成")) {
                    list = wpzfNdhcJlHcTaskService.queryDkTaskByIndex(model);
                } else if (ywhj.equals("1") && state.equals("已完成")) {
                    list = wpzfNdhcJlHcTaskService.queryDkTaskByIndex(model);
                } else if (ywhj.equals("2") && state.equals("待确认")) {
                    list = wpzfNdhcHcdwService.queryQrDkTaskByIndex(model);
                } else if (ywhj.equals("2") && state.equals("已确认")) {
                    list = wpzfNdhcHcdwService.queryQrDkTaskByIndex(model);
                } else if (state.equals("审-核")) {
                    Map<String, Object> map = new HashMap<>();
                    map.put("user_name", loginUser.getUsername());
                    map.put("nick_name", loginUser.getSysUser().getNickName());
                    map.put("dkbh", param.get("dkbh"));
                    map.put("xzqdm", param.get("xzqdm"));
                    map.put("pch", param.get("pch"));
                    map.put("sh_submit", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((new Date()).getTime()));
                    wpzfNdhcShTbService.updateShState(map);
                    model.put("sfck", obj.get("sfck"));
                    list = wpzfNdhcShTbService.queryDkTaskByIndex(model);
                } else if (state.equals("图斑审查")) {
                    list = wpzfNdhcJlHcTaskService.query_tbsc_task_list(model);
                } else if (ywhj.equals("3") && state.equals("待整改")) {
                    list = wpzfNdhcZgTbTaskService.queryDkTaskByIndex(model);
                } else if (ywhj.equals("3") && state.equals("已整改")) {
                    list = wpzfNdhcZgTbTaskService.queryDkTaskByIndex(model);
                } else if (state.equals("图斑查询")) {
                    model.put("dwsfhc", obj.getString("dwsfhc"));
                    model.put("dwsftj", obj.getString("dwsftj"));
                    model.put("jlsfhc", obj.getString("jlsfhc"));
                    model.put("jlsftj", obj.getString("jlsftj"));
                    model.put("jljgqrsfhc", obj.getString("jljgqrsfhc"));
                    model.put("zgsfhc", obj.getString("zgsfhc"));
                    model.put("zgsftj", obj.getString("zgsftj"));
                    model.put("sfxyqr", obj.getString("sfxyqr"));
                    model.put("sfxyzg", obj.getString("sfxyzg"));
                    list = wpzfNdhcTjInfoServiceImpl.queryDkTaskListByIndex(model);
                } else if (state.equals("图斑管理")) {
                    model.put("dwsfhc", obj.getString("dwsfhc"));
                    model.put("dwsftj", obj.getString("dwsftj"));
                    model.put("jlsfhc", obj.getString("jlsfhc"));
                    model.put("jlsftj", obj.getString("jlsftj"));
                    model.put("jljgqrsfhc", obj.getString("jljgqrsfhc"));
                    model.put("zgsfhc", obj.getString("zgsfhc"));
                    model.put("zgsftj", obj.getString("zgsftj"));
                    model.put("sfxyqr", obj.getString("sfxyqr"));
                    model.put("sfxyzg", obj.getString("sfxyzg"));
                    model.put("dkmjType", obj.get("dkmjType"));
                    model.put("dkmjValue", obj.get("dkmjValue"));
                    model.put("dkmjRange", obj.get("dkmjRange"));
                    model.put("gdmjType", obj.get("gdmjType"));
                    model.put("gdmjValue", obj.get("gdmjValue"));
                    model.put("gdmjRange", obj.get("gdmjRange"));
                    model.put("qtnydmjType", obj.get("qtnydmjType"));
                    model.put("qtnydmjValue", obj.get("qtnydmjValue"));
                    model.put("qtnydmjRange", obj.get("qtnydmjRange"));
                    model.put("jsydmjType", obj.get("jsydmjType"));
                    model.put("jsydmjValue", obj.get("jsydmjValue"));
                    model.put("jsydmjRange", obj.get("jsydmjRange"));
                    model.put("wlydmjType", obj.get("wlydmjType"));
                    model.put("wlydmjValue", obj.get("wlydmjValue"));
                    model.put("wlydmjRange", obj.get("wlydmjRange"));
                    list = wpzfNdhcTjInfoServiceImpl.queryDkTaskByIndex(model);
                }
            }
        }
        return AjaxResult.success("切换数据", list);
    }


    @RequestMapping(value = "/export", method = RequestMethod.POST)
    public AjaxResult export(@RequestBody Map<String, Object> param, HttpServletResponse response) {
        List<WpCJ_TB_Hcjg_DTO> item = new ArrayList<>();
        WpzfNdhcExcelUtils excel = new WpzfNdhcExcelUtils();
        String rest = "";
        String msg = "";
        String category = param.get("category") + "";
        String sheetName = "";
        String xzqdm = "";
        try {
            WpCJ_TB_Hcjg_DTO tbhcjg = new WpCJ_TB_Hcjg_DTO();

            List<Map<String, Object>> ColNamelist = wpzfNdhcCommonServiceImpl.queryHcJgByColumnName();   //获取核查结果的所有列明
            List<WpCjTbhcjgDTO> list = wpzfNdhcCommonServiceImpl.getTbhcjglist(param);  //核查结果
            tbhcjg.setWpCjTbhcjgDTOS(list);
            tbhcjg.setwpCjTbhcjgDTOS_ColumnNameList(ColNamelist);
            item.add(tbhcjg);


            List<WpCjTbhcjgHftgzmwjDTO> hftgzmwjList = wpzfNdhcTbhcjgService.getHftgzmwj(param);  //核查结果 合法*******动态批文
            if (hftgzmwjList.size() > 0) {
                List<Map<String, Object>> HftgzmwjByColumnName = wpzfNdhcCommonServiceImpl.queryHftgzmwjByColumnName();  //合法*******动态批文 列名

                tbhcjg.setWpCjTbhcjgHftgzmwjDTO(hftgzmwjList);
                tbhcjg.setwpCjTbhcjgHftgzmwjDTO_ColumnNameList(HftgzmwjByColumnName);
                item.add(tbhcjg);
            }


            List<WpCjTbhcjgWftgzmwjDTO> WftgzmwjList = wpzfNdhcTbhcjgService.getWftgzmwj(param);  //核查结果 违法*******违法提供证明文件
            if (WftgzmwjList.size() > 0) {
                List<Map<String, Object>> WftgzmwjByColumnName = wpzfNdhcCommonServiceImpl.queryWfpzwhByColumnName();  //列名

                tbhcjg.setWpCjTbhcjgWftgzmwjDTO(WftgzmwjList);
                tbhcjg.setwpCjTbhcjgHftgzmwjDTO_ColumnNameList(WftgzmwjByColumnName);
                item.add(tbhcjg);

            }
            List<WpCjTbhcjgWfpzwhDTO> WfpzwhList = wpzfNdhcTbhcjgService.getWfpzwh(param);  //核查结果 违法*******批准文号
            if (WfpzwhList.size() > 0) {
                List<Map<String, Object>> WfpzwhByColumnName = wpzfNdhcCommonServiceImpl.queryWftgzmwjByColumnName();  //列名

                tbhcjg.setWpCjTbhcjgWfpzwhDTO(WfpzwhList);
                tbhcjg.setwpCjTbhcjgWfpzwhDTO_ColumnNameList(WfpzwhByColumnName);
                item.add(tbhcjg);
            }


            List<WpCjTbhcjgQtpzwhDTO> QtpzwhList = wpzfNdhcTbhcjgService.getQtpzwh(param);  //核查结果  其他*******批准文号
            if (QtpzwhList.size() > 0) {
                List<Map<String, Object>> QtpzwhByColumnName = wpzfNdhcCommonServiceImpl.queryQtpzwhByColumnName();  //列名

                tbhcjg.setWpCjTbhcjgQtpzwhDTO(QtpzwhList);
                tbhcjg.setwpCjTbhcjgQtpzwhDTO_ColumnNameList(QtpzwhByColumnName);
                item.add(tbhcjg);
            }
            List<WpCjTbhcjgQtsfzygdDTO> QtsfzygdList = wpzfNdhcTbhcjgService.getQtsfzygd(param);  //核查结果 其他*******是否占用耕地
            if (QtsfzygdList.size() > 0) {
                List<Map<String, Object>> QtsfzygdByColumnName = wpzfNdhcCommonServiceImpl.queryQtsfzygdByColumnName();  //列名

                tbhcjg.setWpCjTbhcjgQtsfzygdDTO(QtsfzygdList);
                tbhcjg.setwpCjTbhcjgQtsfzygdDTO_ColumnNameList(QtsfzygdByColumnName);
                item.add(tbhcjg);
            }
            List<WpCjTbhcjgQtsftgxxydssDTO> QtsftgxxydssList = wpzfNdhcTbhcjgService.getQtsftgxxydss(param);  //核查结果-是否提供先行用地手续
            if (QtsftgxxydssList.size() > 0) {
                List<Map<String, Object>> QtsftgxxydssByColumnName = wpzfNdhcCommonServiceImpl.queryQtsftgxxydssByColumnName();  //列名

                tbhcjg.setWpCjTbhcjgQtsftgxxydssDTO(QtsftgxxydssList);
                tbhcjg.setwpCjTbhcjgQtsftgxxydssDTO_ColumnNameList(QtsftgxxydssByColumnName);
                item.add(tbhcjg);
            }
            rest = excel.export(response, category, item, xzqdm, param);
            if (rest.equals("success")) {
                msg = "导出成功";
            } else {
                msg = "导出失败";
            }
            return AjaxResult.success(msg, rest);
        } catch (Exception e) {
            e.printStackTrace();
            msg = "导出失败";
        }
        return AjaxResult.error(msg, -1);
    }


    /*根据当前用户获取所有批次*/
    @RequestMapping(value = "/get_user_pchlist", method = RequestMethod.POST)
    public AjaxResult get_user_pchlist(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("username", loginUser.getUsername());
        //获取当前用户所有已完成的任务

        List<Map<String, Object>> rest = wpzfNdhcCommonServiceImpl.get_user_pchlist(param);
        if (rest != null) {

            return AjaxResult.success("获取所有批次成功", rest);
        }

        return AjaxResult.error("获取所有批次失败", -1);
    }

    /*根据当前单位所有的人员*/
    @RequestMapping(value = "/get_unit_userlist", method = RequestMethod.POST)
    public AjaxResult get_unit_userlist(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
        //获取当前用户所有已完成的任务
        List<Map<String, Object>> rest = wpzfNdhcCommonServiceImpl.get_unit_userlist(param);
        return AjaxResult.success("获取当前单位所有的人员成功", rest);
    }

    //根据当前监理获取所有批次号
    @RequestMapping(value = "/getJlPch", method = RequestMethod.POST)
    public AjaxResult getJlPch(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("username", loginUser.getUsername());
        List<Map<String, Object>> rest = wpzfNdhcCommonServiceImpl.getJlPch(param);
        if (rest != null) {
            return AjaxResult.success("根据当前监理获取所有批次号 成功", rest);
        }
        return AjaxResult.error("根据当前监理获取所有批次号 失败", -1);
    }

    //获取年度核查年份信息
    @RequestMapping(value = "/getNdhcYear", method = RequestMethod.POST)
    public AjaxResult getNdhcYear(@RequestBody Map<String, Object> param) {
        List<Map<String, Object>> rest = wpzfNdhcCommonServiceImpl.getNdhcYear(param);
        if (rest != null) {
            return AjaxResult.success("获取年份成功", rest);
        }
        return AjaxResult.error("根据当前监理获取所有批次号 失败", -1);
    }

    //保存pdf导出信息
    @RequestMapping(value = "/savePdfInfo", method = RequestMethod.POST)
    public AjaxResult savePdfInfo(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_name", loginUser.getUsername());
        param.put("nick_name", loginUser.getSysUser().getNickName());
        Integer rest = wpzfNdhcCommonServiceImpl.savePdfInfo(param);
        if (rest > 0) {
            return AjaxResult.success("保存pdf导出信息 成功", rest);
        } else {
            return AjaxResult.error("保存pdf导出信息 失败", rest);
        }
    }

    //获取pdf导出信息
    @RequestMapping(value = "/getPdfInfo", method = RequestMethod.POST)
    public AjaxResult getPdfInfo(@RequestBody Map<String, Object> param) {
        Map<String, Object> rest = wpzfNdhcCommonServiceImpl.getPdfInfo(param);
        return AjaxResult.success("获取pdf导出信息", rest);
    }

    //获取核查结果说明
    @RequestMapping(value = "/getHcjgsmlx", method = RequestMethod.POST)
    public AjaxResult getHcjgsmlx(@RequestBody Map<String, Object> param) {
        Map<String, Object> rest = wpzfNdhcCommonServiceImpl.getHcjgsmlx(param);
        return AjaxResult.success("获取核查结果说明", rest);
    }

    //获取pdf
    @RequestMapping(value = "/getPDF", method = RequestMethod.POST, produces = {"application/pdf;charset=UTF-8"})
    public void getPDF(@RequestBody Map<String, Object> param, HttpServletResponse response) {
        try {
            String rest = wpzfNdhcCommonServiceImpl.getPDF(param, response);
            String msg = "";
            if (rest.contains("error")) {
                msg = "pdf导出失败";
            } else {
                msg = "pdf导出成功";
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
